package com.yuhs.zixing.study.multithread.mashibing.t002lock.l003;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Function:
 *
 * @Author yuhongsheng
 * @Date: 2023-12-23 21:16:34
 */
@Slf4j
public class Lock003CAS001 {


    AtomicInteger count = new AtomicInteger(0);

    void add() {
        for (int i = 0; i < 10; i++) {
            count.incrementAndGet();
        }
    }

    public static void main(String[] args) {
        Lock003CAS001 cas001 = new Lock003CAS001();
        for (int i = 0; i < 10; i++) {
            new Thread(cas001::add, "线程" + i).start();
        }
        log.atInfo().log("值 {}", cas001.count);
    }

}
